<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>签约开通</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->
</head>
<body>
<div class="zz-header">
    尊敬的您好，欢迎申请使用享云收款
</div>
<div class="zz-list">
    <ul>
        <li>
            <span class="zz-left">店铺名称</span
            ><span class="zz-right"></span>
        </li>
        <li>
            <span class="zz-left">产品名称</span
            ><span class="zz-right"></span>
        </li>
        <li>
            <span class="zz-left">支付宝费率</span
            ><span class="zz-right"></span>
        </li>
        <li>
            <span class="zz-left">微信费率</span
            ><span class="zz-right"></span>
        </li>
        <li class="zz-position">
            <span class="zz-left">手机号</span
            ><input class="zz-code-num zz-phone-code" type="number" value="" disabled/>
            <input class="zz-code" type="button" value="获取验证码"/>
        </li>
        <li>
            <span class="zz-left">验证码</span
            ><input class="zz-code-num zz-verification-code" type="number" placeholder="请输入验证码"/>
        </li>
    </ul>

</div>
<div class="zz-read">
    <span class="zz-check"></span>
    <span>同意</span>
    <a href="http://m.soopay.net/c/static/jhizljjl">《享云商户注册服务协议》</a>
    <span>&nbsp;</span>
    <a href="http://m.soopay.net/c/static/eqcexqxv">《立马付服务协议》</a>
</div>
<input class="footer" type="button" value="立即收款">
</body>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript">
	var data = '';
	
    function bindHTML() {
		var alipayRates = data["alipayRates"]/1000+ "%";
		var wecatRates = data["wecatRates"]/1000+ "%";
        var str = '';

        str += '<li>';
        str += '<span class="zz-left">店铺名称</span>';
        str += '<span class="zz-right zz-store-name">' + data["toreShortName"] + '</span>';
        str += '</li>';
        str += '<li>';
        str += '<span class="zz-left">产品名称</span>';
        str += '<span class="zz-right">' + data["productName"] + '</span>';
        str += '</li>';
        str += '<li>';
        str += '<span class="zz-left">支付宝费率</span>';
        str += '<span class="zz-right">' + alipayRates + '</span>';
        str += '</li>';
        str += '<li>';
        str += '<span class="zz-left">微信费率</span>';
        str += '<span class="zz-right">' + wecatRates + '</span>';
        str += '</li>';
        str += '<li class="zz-position">';
        str += '<span class="zz-left">手机号</span>';
        str += '<span class="zz-right">' + data["bankMobileId"] + '</span>';
        str += '<input class="zz-code-num zz-phone-code zz-phone-color" type="hidden" bankMobileId="' + data["bankMobileId"] + '" merId="' + data["merId"] + '" storeId="' + data["storeId"] + '" disabled/>';
        str += '<input class="zz-code" type="button" value="获取验证码"/>';
        str += '</li>';
        str += '<li>';
        str += '<span class="zz-left">验证码</span>';
        str += '<input class="zz-code-num zz-verification-code" type="number" placeholder="请输入验证码" maxlength="6"/>';
        str += '</li>';
        $(".zz-list ul").html(str);
    }

    //初始化接口
    $.ajax({
        //url: "../json/index.json",
        url: utils.ajaxUrl()+"h5/sign/receiver/getStoreBySign",
        data: {},
        async: false,
        type: 'get',
        success: function (res) {
        	console.log(res);
            if (res && res.retCode == '0000') {
                data = res["storeVo"];
                console.log(data);
                $(".zz-header").html("尊敬的" + res.name + "您好，欢迎申请使用享云收款");
                bindHTML()
            } else {
                new $.modal({
                    content: res.retMsg,//弹框内容
                    showcontent: true,//false为弹出框组件二，true为弹出框组件一
                }).show();
                $(".footer").attr("disabled", "true");
            }
        }
    });
</script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>

<script charset="utf-8" type="text/javascript">
    //点击获取验证码
    $code.click(function () {
        var that = $(this);
 		var storeId = $phone_code.attr("storeId");
 		//storeId = 60001101;
 		
        var bankMobileId = $phone_code.attr("bankMobileId");
        $.ajax({
            url: utils.ajaxUrl()+"h5/sign/send",
            async: false,
            data: {
                storeId: storeId
            },
            type: 'get',
            success: function (res) {
            	var res = JSON.parse(res);
            	console.log(res)
                if (res && res.retCode == '0000') {
                	//alert(res.verifyCode);
                	utils.time(that);
                    //utils.effectivePhone(bankMobileId, that, utils.time, that);
                } else {
                    new $.modal({
                        content: res.retMsg,//弹框内容
                        showcontent: true,//false为弹出框组件二，true为弹出框组件一
                    }).show(that);
                }
            }
        });
    });

    function check() {
        if ($check.hasClass("zz-not-check")) {
            $check.removeClass("zz-not-check");
        } else {
            $check.addClass("zz-not-check");
        }
    }

    $check.click(function () {
        check();
    });

    $footer.click(function () {
        //判断验证码
        if (!utils.effectiveNum($verification_code.val(), $footer)) {
            return false
        }

//        判断勾是否被选中
        if ($check.hasClass("zz-not-check")) {
            new $.modal({
                content: '请您阅读并同意服务协议。',//弹框内容
                showcontent: true,//false为弹出框组件二，true为弹出框组件一
            }).show($footer);
            return false;
        }
        var merId = $phone_code.attr("merId");
        var storeId = $phone_code.attr("storeId");
		var verifyCode = $verification_code.val();
		
		new $.modal({
            content: "加载中",
            animation: true//调用动画
        }).show();
		//$footer.attr("disabled", "true");
        $.ajax({
            url: utils.ajaxUrl()+"h5/sign/receiver/updateStoreSign",
            data: {
                merId: merId,
                storeId: storeId,
                verifyCode: verifyCode
            },
            async: false,
            type: 'get',
            success: function (res) {
            	//console.log(res);
                if (res && res.retCode == "2") {
         window.location.href = "../../html/h5/success.html";
         //$footer.removeAttr("disabled");
         new $.modal({
         animation: true,//调用动画
}).hide();
     } else if(res.retCode == "3"){
         window.location.href = "../../html/h5/successYH.html";
         //$footer.removeAttr("disabled");
         new $.modal({
             animation: true,//调用动画
         }).hide();
     }else {
     
       new $.modal({
         animation: true,//调用动画
}).hide(0);

         new $.modal({
             content: res.retMsg,//弹框内容
             showcontent: true,//false为弹出框组件二，true为弹出框组件一
         }).show($footer);
     }
            }
        });
    })
</script>
</html>